<?php
class Match {

    var $id;
    var $season;
    var $gate;
    var $homeRec;
    var $awayRec;
    var $type;
    var $datePlayed;
    var $teamsUpdated;

    function Match() {
    }

	function init($id, $gate, $homeRec, $awayRec, $type, $datePlayed, $teamsUpdated, $season = NULL) {
	    $this->id = $id;
	    $this->gate = $gate;
	    $this->homeRec = $homeRec;
	    $this->awayRec = $awayRec;
	    $this->type = $type;
	    $this->datePlayed = $datePlayed;
	    $this->teamsUpdated = $teamsUpdated;
	}
	
    function getMatchTypes() {
        return array (
            "League" => "League",
            "Semi-Final" => "Semi-Final",
            "Final" => "Final",
            "Other" => "Other"
        );
    }
    
    function isFinal() {
        return 0 == strcmp("Final", $this->type);
    }

    function getDescription() {
        global $teams;
        $homeTeam = $teams->getTeam($this->homeRec->teamId);
        $awayTeam = $teams->getTeam($this->awayRec->teamId);
        if (isset ($this->homeRec->score)) {
            return "" . $homeTeam->name . " " . $this->homeRec->score . "-" . $this->awayRec->score . " " . $awayTeam->name;
        }
        return "" . $homeTeam->name . " vs " . $awayTeam->name;
    }
}

?>